<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                template="../WEB-INF/facelets/layout.xhtml"
                xmlns:c="http://java.sun.com/jsp/jstl/core"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:p="http://primefaces.prime.com.tr/ui">
    <ui:param name="title" value="Show Post"/>
    <ui:param name="headerTitle" value="Show Post"/>
    <ui:define name="content">
        <f:metadata>
            <f:viewParam name="postId" value="#{showPostViewBean.id}"/> 
        </f:metadata>

        <h:outputText value="#{showPostViewBean.post.title}" style="font-size: 2em"/>  
        By: #{showPostViewBean.post.userClass.userName}
        <br/>
        <h:outputText value="#{showPostViewBean.post.content}" style="font-size: 1em; word-wrap:break-word; "/>
        <br/>
        <c:if test="${showPostViewBean.user !=null}">
            <hr/>
            <h:outputText value="Add comment:" style="font-size:1.5em" />
            <h:form id="commentInput">
                <br/>
                <p:inputTextarea  title="Content" style="width:20%;height:20px;" 
                                  effectDuration="400"   value="#{addCommentBackingBean.comment}"/> 
                <h:commandButton  action="showPost.jsf?faces-redirect=true&amp;includeViewParams=true" actionListener="#{addCommentControllerBean.addComment}" value="Submit"/>
            </h:form>
        </c:if>
        <hr/>
        <c:forEach items="#{showPostViewBean.post.comments}" var="comment" id="comments">
            By: <h:outputText value="#{comment.commentAuthor.userName}" style="font-weight: bold"/><br/> <h:outputText value="#{comment.comment}" style="word-wrap:break-word"/>
            <br/>
        </c:forEach>
    </ui:define>
</ui:composition>

